package com.finance.cooperate.feature.builder.submodel.support.intermediate;

import com.finance.cooperate.common.constant.Constant;
import com.finance.cooperate.common.utils.StringUtil;
import com.finance.cooperate.feature.base.ReaderImpl;
import com.finance.cooperate.feature.core.feature.FeatureDefinition;

import java.util.Map;

public class IntermediateFeature001 extends ReaderImpl {
    @Override
    public Map<String, String> read(String userId) {


        // 年龄加工
        String ageStr = super.get(FeatureDefinition.f_identity_birthday_age);

        if (!StringUtil.isEmptyOrNvl(ageStr)) {
            int age = Integer.parseInt(ageStr);

            if (age > -1) {
                age = (age / 5) * 5;

                super.put(FeatureDefinition.f_intermediate_feature_base_age_.getValue() + age, Constant.IS_HIT);
            }

        }

        // 性别加工
        String genderStr = super.get(FeatureDefinition.f_identity_gender);

        if (!StringUtil.isEmptyOrNvl(genderStr)) {
            int gender = Integer.parseInt(genderStr);

            if (gender > -1) {
                super.put(FeatureDefinition.f_intermediate_feature_base_gender_.getValue() + gender, Constant.IS_HIT);
            }

        }


        // 婚姻状态加工
        String maritalStr = super.get(FeatureDefinition.f_personal_marital_status);

        if (!StringUtil.isEmptyOrNvl(maritalStr)) {
            int marital = Integer.parseInt(maritalStr);

            if (marital > -1) {
                super.put(FeatureDefinition.f_intermediate_feature_base_marital_.getValue() + marital, Constant.IS_HIT);
            }

        }
        

        return super.getResult();
    }
}
